package xxl.ioc.utils 
{
	/**
	 * ...
	 * @author XXL
	 */
	public class FunctionApplyUtil 
	{
		
		[Inline]
		public static function Apply(target:Object, methodName:String, params:Array):void
		{
			const fun:Function = target[methodName] as Function;
			if (fun)
			{
				var len:int = params.length;
				if (len == 0)
				{
					fun();
				}
				else if (len == 1)
				{
					fun(params[0]);
				}
				else if (len == 2)
				{
					fun(params[0], params[1]);
				}
				else if (len == 3)
				{
					fun(params[0], params[1], params[2]);
				}
				else if (len == 4)
				{
					fun(params[0], params[1], params[2], params[3]);
				}
				else if (len == 5)
				{
					fun(params[0], params[1], params[2], params[3], params[4]);
				}
				else
				{
					fun.apply(target, params);
				}
			}
		}
		
	}

}